#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e4+10;
int n,m,q,e[MAXN][MAXN],fa[MAXN];
void dfs(int u)
{
	for(int v=1;v<=n;++v)
	{
		if(v==u||v==fa[u]||!e[u][v])continue;
		dfs(v);
	}
	int k=u;
	while(true)
	{
		if(rand()%10<2||e[k][fa[k]]==2||!fa[k])
		{
			if(k==u||k==fa[u])break;
			++m;
			printf("%d %d %d\n",u,k,rand()%20+1);
			break;
		}
		e[k][fa[k]]=2;
		k=fa[k];
	}
	return;
}
int main()
{
	srand(time(0));
	n=10000,m=n-1,q=10000;
	for(int i=2;i<=n;++i)
	{
		int v=rand()%(i-1)+1;
		e[i][v]=e[v][i]=1;
		fa[i]=v;
		printf("%d %d %d\n",i,v,rand()%20+1);
	}
	dfs(1);
	for(int i=1;i<=q;++i)
	{
		int t1=rand()%n+1,t2;
		while((t2=rand()%n+1)==t1);
		printf("%d %d\n",t1,t2);
	}
	printf("%d %d %d\n",n,m,q);
	return 0;
}
